package com.michaelbulava.TFS.ui.dialogs.connect;

//import com.fasterxml.jackson.databind.DeserializationFeature;
//import com.fasterxml.jackson.databind.ObjectMapper;
import com.intellij.openapi.diagnostic.Logger;
import com.michaelbulava.TFS.log.FileLogger;

/**
 * Created by mbulava on 7/3/2015.
 */
public class NotifyTokenWebBrowserFunction {//implements BrowserFunction {
    private static final Logger log = FileLogger.getInstance(NotifyTokenWebBrowserFunction.class);

    public NotifyTokenWebBrowserFunction() {

    }

//        @Override
//        public Object invoke(JWebBrowser jWebBrowser, Object... arguments) {
//
//            ACSCredentialsDialog.log.debug("window.notifyToken(...) invoked");
//
//            Check.notNull(arguments, "arguments");
//            Check.isTrue(arguments.length == 1, "arguments length");
//            Check.isTrue(arguments[0] instanceof String, "argument[0]");
//
//            String arg = (String)arguments[0];
//            ACSCredentialsDialog.log.debug("   argument = " + arg);
//            try {
//                Map<String, List<String>> tokenData = (Map)getObjectMapper().readValue(arg, Map.class);
//                onNotifyToken((List)tokenData.get("securityToken"));
//            } catch (Exception e) {}
//            ACSCredentialsDialog.this.checkCredentials();
//
//            return null;
//        }

//    private ObjectMapper getObjectMapper()
//    {
//        ObjectMapper objectMapper = new ObjectMapper();
//
//        objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
//        objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
//
//        return objectMapper;
//    }
    public void notifyToken(Object[] input){
        log.info("got here");
    }

    public void notifyError(Object[] input){
        log.info("got here");
    }
//        @Override
//        public JSValue invoke(JSValue... jsValues) {
//            log.debug("window.notifyToken(...) invoked");
//
//            Check.notNull(jsValues, "arguments");
//            Check.isTrue(jsValues.length == 1, "arguments length");
////            Check.isTrue(arguments[0] instanceof String, "argument[0]");
////
////            String arg = (String)arguments[0];
////            ACSCredentialsDialog.log.debug("   argument = " + arg);
////            try {
////                Map<String, List<String>> tokenData = (Map)getObjectMapper().readValue(arg, Map.class);
////                onNotifyToken((List)tokenData.get("securityToken"));
////            } catch (Exception e) {}
////            ACSCredentialsDialog.this.checkCredentials();
//
//            return null;
//        }
}